import { transFormData } from '@/utils'
import { getPermissionList } from '@/api/permission'

const getDefaultState = () => {
  return {
    tableData: []
  }
}
const state = getDefaultState()

const mutations = {
  updatePermissionList(state, tableData) {
    state.tableData = tableData
  }
}
const actions = {
// 获取数据=====================================================
  getPermissionList({ commit }) {
    return new Promise(async resolve => {
      const res = await getPermissionList()
      commit('updatePermissionList', transFormData(res.data, { id: 'id', pid: 'pid' }))
      resolve()
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
